#pragma once

class CAudioManager
{
public:
	CAudioManager();
	void setFormat();

	HWND m_hWnd;
	LPDIRECTSOUND m_pDS;
	LPDIRECTSOUNDBUFFER m_pDSBuf;
	float m_fVolume;
	float m_fPan;
	int m_iSpeaker;
	float m_fuck5[16];
	int m_fuck6; 
};

class CClipSound;
class CClipSoundContext
{
public:
	CClipSoundContext();
	~CClipSoundContext();
	BOOL init(float freq, int samplebits, int channel, void* wave,int length, int algo,int bufnum);
	BOOL createBuffer(LPDIRECTSOUNDBUFFER *buf,int bufnum,BYTE *pbuf,int length,WAVEFORMATEX *wf);
	BOOL initBuffer(LPDIRECTSOUNDBUFFER buf);
	int getFreeBufferIndex(int rhint);
	BOOL play(CClipSound* sound,int bufidx,BOOL loop);
	int playing(CClipSound*sound);

	int m_algo;
	int m_bufnum;
	BYTE *m_buf;
	LPDIRECTSOUNDBUFFER *m_buf1;
	CClipSound **m_buf2;
	float m_freq;
	int m_samplebits;
	int m_channel;
	BYTE *m_pbuf;
	int m_length;
};

class CClipSound
{
public:
	CClipSound(CClipSoundContext *cont,float volume,float pan,float pitch);
	void setPitch(float pitch);
	void setVolume(float volume);
	int getVolume(float volume);
	void setPan(float pan);
	int getPan();
	BOOL play(int bufidx, BOOL loop){return m_cont->play(this,bufidx,loop);}
	int playing(){return m_cont->playing(this);}
	void stop();

	CClipSoundContext *m_cont;
	int m_id;
	int m_fuck2;
	float m_volume;
	float m_pan;
	float m_pitch;
	BOOL m_loop;
	int m_fuck4;
};